#include "stdafx.h"

/**
* @brief BitmapBits
*
* BitmapBits
*
* @param LPCTSTR lpszResource
* @param int * Bits
* @return void
*/
void BitmapBits(LPCTSTR lpszResource, int *Bits)
{
	CDC objDC;
	objDC.CreateCompatibleDC();

	CBitmap objBmp;
	objBmp.LoadBitmap(lpszResource);

	BITMAPINFO bi = {0};

	bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bi.bmiHeader.biWidth = 452;
	bi.bmiHeader.biHeight = -206;
	bi.bmiHeader.biPlanes = 1;
	bi.bmiHeader.biBitCount = 24;
	bi.bmiHeader.biCompression = BI_RGB;
	bi.bmiHeader.biSizeImage = 452 * 206 * 3;

	static BYTE imageBits[452 * 206 * 3] = {0};

	int r = GetDIBits(objDC, objBmp, 0, 206, imageBits, &bi, DIB_RGB_COLORS);

	for (int i = 0;i < 452;i++)
	{
		for (int j = 0;j < 206;j++)
		{
			int idx = j * 452 + i;
			Bits[idx] = (imageBits[idx*3] + imageBits[idx*3+1] + imageBits[idx*3+2]);
		}
	}
}